package com.shoppingmall.service.impl;

import com.google.common.collect.Maps;
import com.shoppingmall.common.ServletResponse;
import com.shoppingmall.dao.OrderMapper;
import com.shoppingmall.dao.ProductMapper;
import com.shoppingmall.dao.UserMapper;
import com.shoppingmall.service.StatisticService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * Created by
 *
 * @author touni
 * @date 2019/3/26
 * @time 10:39
 */
@Service
public class StatisticServiceImpl implements StatisticService {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private ProductMapper productMapper;

    @Autowired
    private OrderMapper orderMapper;




    /**
     * 统计用户数量  商品数量 订单数量
     *
     * @return
     */
    @Override
    public ServletResponse baseCount() {
        //统计用户数量
        Integer userCount = userMapper.selectCountUser();
        //统计产品的数量
        Integer productCount = productMapper.selectCountProduct();
        //统计订单的数量
        Integer orderCount = orderMapper.selectCountOrder();
        Map<String, Integer> resultMap = Maps.newHashMap();
        resultMap.put("userCount",userCount);
        resultMap.put("productCount",productCount);
        resultMap.put("orderCount",orderCount);
        return ServletResponse.createBySuccess(resultMap);



    }






















}
